home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1993 Michael D. Bayne.
- * All rights reserved.
- *
- * Please see the documentation accompanying the distribution for distribution
- * and disclaimer information.
- */
-
- #include <exec/memory.h>
-
- #include <dos/dos.h>
-
- #include <intuition/intuition.h>
- #include <intuition/screens.h>
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <libraries/asl.h>
- #include <graphics/text.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/asl_protos.h>
-
- #include <string.h>
-
- #include "/Garshnelib/Garshnelib_protos.h"
- #include "/Garshnelib/Garshnelib_pragmas.h"
-
- #include "Text.h"
- #include "Text_rev.h"
- #include "//defs.h"
- #include "/main.h"
-
- struct ModulePrefs
- {
- LONG Mode;
- LONG Delay;
- LONG Cycle;
- BYTE Text[128];
- BYTE fName[64];
- struct TextAttr Font;
- };
-
- struct ModulePrefs nP;
- VOID *OldPrefs = 0L;
- STATIC const UBYTE VersTag[] = VERSTAG;
-
- int BT_SAVEClicked( VOID )
- {
- if( OldPrefs )
- {
- CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
- SavePrefs( OldPrefs );
- OldPrefs = 0L;
- }
-
- return QUIT;
- }
-
- int BT_TESTClicked( VOID )
- {
- MessageServer( BM_SENDBLANK );
-
- return OK;
- }
-
- int BT_SCREENClicked( VOID )
- {
- ScreenModeRequest( TextWnd, &nP.Mode, 0L );
-
- return OK;
- }
-
- int BT_CANCELClicked( VOID )
- {
- OldPrefs = 0L;
-
- return QUIT;
- }
-
- int SL_DELAYClicked( VOID )
- {
- nP.Delay = TextMsg.Code;
-
- return OK;
- }
-
- int CY_CYCLEClicked( VOID )
- {
- nP.Cycle = TextMsg.Code;
-
- return OK;
- }
-
- int BT_FONTClicked( VOID )
- {
- struct FontRequester *fReq;
- struct Library *AslBase;
-
- if(!( AslBase = OpenLibrary( "asl.library", 37L )))
- return OK;
- fReq = AllocAslRequestTags( ASL_FontRequest, ASL_FontName, ( LONG )nP.fName,
- ASL_FontHeight, nP.Font.ta_YSize, ASL_MaxHeight, 100, TAG_DONE );
- if( fReq )
- {
- if( AslRequestTags( fReq, ASLFO_Window, TextWnd, ASLFO_SleepWindow, TRUE, ASLFO_TitleText,
- ( LONG )"Please choose a font...", 0L ))
- {
- CopyMem( fReq->fo_Attr.ta_Name, nP.fName, 31 );
- nP.Font.ta_YSize = fReq->fo_Attr.ta_YSize;
- }
- FreeAslRequest( fReq );
- }
- CloseLibrary( AslBase );
-
- return OK;
- }
-
- int ST_TXTClicked( VOID )
- {
- strcpy( nP.Text, GetString( TextGadgets[GD_ST_TXT] ));
-
- return OK;
- }
-
- #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( TextGadgets[Gad], TextWnd, 0L, Tag, Val, TAG_END )
-
- int TextVanillaKey( VOID )
- {
- switch( TextMsg.Code ) {
- case 's':
- return BT_SAVEClicked();
- case 't':
- return BT_TESTClicked();
- case 'd':
- return BT_SCREENClicked();
- case 'c':
- return QUIT;
- case 'f':
- return BT_FONTClicked();
- case 'l':
- BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, Inc( nP.Delay, 1, 120 ));
- return OK;
- case 'L':
- BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, Dec( nP.Delay, 1, 0 ));
- return OK;
- case 'r':
- ActivateGadget( TextGadgets[GD_ST_TXT], TextWnd, 0L );
- return OK;
- default:
- return OK;
- }
- }
-
- #define ComputeX( x ) ((( FontX * x ) + 4 ) / 8 )
- #define ComputeY( x ) ((( FontY * x ) + 4 ) / 8 )
-
- VOID DoPrefs( LONG command, VOID *Prefs )
- {
- switch( command )
- {
- case STARTUP:
- OldPrefs = Prefs;
- CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
- if( !SetupScreen())
- {
- TextLeft = ( Scr->Width - ComputeX( TextWidth ))/2 - Scr->WBorRight;
- TextTop = ( Scr->Height - ComputeY( TextHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
- if( !OpenTextWindow())
- {
- BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, nP.Delay );
- BL_SetGadgetAttrs( GD_CY_CYCLE, GTCY_Active, nP.Cycle );
- BL_SetGadgetAttrs( GD_ST_TXT, GTST_String, nP.Text );
- }
- CloseDownScreen();
- }
- break;
- case IDCMP:
- if( HandleTextIDCMP() != QUIT )
- break;
- case KILL:
- CloseTextWindow();
- break;
- }
- }
-
- LONG WndSignal( VOID )
- {
- return TextWnd ? 1L << TextWnd->UserPort->mp_SigBit : 0L;
- }
-
- VOID FillDefaults( VOID *Prefs )
- {
- struct ModulePrefs *NewPrefs = ( struct ModulePrefs * )Prefs;
-
- NewPrefs->Mode = getTopScreenMode();
- NewPrefs->Delay = 60L;
- NewPrefs->Cycle = 0L;
- NewPrefs->Font.ta_YSize = 11;
- NewPrefs->Font.ta_Style = FS_NORMAL;
- NewPrefs->Font.ta_Flags = FPB_ROMFONT;
- strcpy( NewPrefs->fName, "topaz.font" );
- strcpy( NewPrefs->Text, "Every good boy deserves fudge." );
- }
-